﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PowerSupply : MonoBehaviour
{
    private List<IElectricalEquipment> electraicalList = new List<IElectricalEquipment>();
    public bool isOpen = true;
    public void Open()
    {
        if (isOpen)
        {
            return;
        }
        isOpen = true;
        foreach (var item in electraicalList)
        {
            item.Open();
        }
    }

    public void Close()
    {
        if (!isOpen)
        {
            return;
        }
        isOpen = false;
        foreach (var item in electraicalList)
        {
            item.Close();
        }
    }

    public void AddEquipment(IElectricalEquipment equipment)
    {
        electraicalList.Add(equipment);
    }

    public void RemoveEquipment(IElectricalEquipment equipment)
    {
        if (electraicalList.Contains(equipment))
        {
            electraicalList.Remove(equipment);
        }
    }
}
